package com.example.xm.ui.home.fragments.activity_photo;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.xm.R;
import com.example.xm.adapter.HomeAdapter.ActivityPhotoImageAdapter;
import com.example.xm.bean.HomeBean.HomePhotoBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class PhotoActivity extends AppCompatActivity {

    @BindView(R.id.iv_finish_photo)
    ImageView ivFinishPhoto;
    @BindView(R.id.rl_activity)
    RelativeLayout rlActivity;
    @BindView(R.id.iv_head_photo_activity)
    ImageView ivHeadPhotoActivity;
    @BindView(R.id.tv_name_activity)
    TextView tvNameActivity;
    @BindView(R.id.tv_date_activity)
    TextView tvDateActivity;
    @BindView(R.id.tv_guanzhu_activity)
    TextView tvGuanzhuActivity;
    @BindView(R.id.tv_title_activity)
    TextView tvTitleActivity;
    @BindView(R.id.rlv_activity)
    RecyclerView rlvActivity;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_photo);
        ButterKnife.bind(this);
        initView();
        initListener();
    }

    private void initListener() {
        ivFinishPhoto.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void initView() {
        Intent intent = getIntent();
        HomePhotoBean.DataBean.DynamicsBean bean = (HomePhotoBean.DataBean.DynamicsBean) intent.getSerializableExtra("bean");
        RequestOptions requestOptions = new RequestOptions().circleCrop();
        Glide.with(this).load(bean.getHeadUrl()).apply(requestOptions).into(ivHeadPhotoActivity);
        tvNameActivity.setText(bean.getNickName());
        tvTitleActivity.setText(bean.getContent());
        tvDateActivity.setText(bean.getCreateTime());
        rlvActivity.setLayoutManager(new LinearLayoutManager(this));
        List<HomePhotoBean.DataBean.DynamicsBean.ImagesBean> images = bean.getImages();
        ActivityPhotoImageAdapter activityPhotoImageAdapter = new ActivityPhotoImageAdapter(this, images);
        rlvActivity.setAdapter(activityPhotoImageAdapter);
    }
}